function df

figHandles = get(0,'Children');
figHandles = sort(findobj('Type','figure'));

num_figs=length(figHandles);

mon_pos=get(0,'monitorposition');
dxtot=-min(mon_pos(:,1))+max(mon_pos(:,3));
minx=min(mon_pos(:,1))+20;
dytot=min(mon_pos(:,4));

if num_figs<7
    num_rows=1;
else
    num_rows=2;
end

num_cols=ceil(num_figs/num_rows);
dx=floor(dxtot/num_cols);
dy=floor(dytot/num_rows);

cnt=0;
for ind=1:num_cols
    for knd=num_rows:-1:1
        cnt=cnt+1;
        if cnt<=num_figs
            set(figHandles(cnt),'position',[minx+(ind-1)*dx 1+(knd-1)*dy dx-50 dy-100]);
            figure(figHandles(cnt))
        end
    end
end